local mode = require("./modes")
local git_url = (mode.isHttps() and { "https://mirror.ghproxy.com/https://github.com/" } or { "git@github.com:" })[1]

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    git_url .. "folke/lazy.nvim",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

local core = {}
local standard = {}
local pro = {}

require("lazy").setup({
  { "kaicataldo/material.vim", priority = 1000 },
  { "rose-pine/neovim", name = "rose-pine", priority = 1000 },
  { "nvim-lua/plenary.nvim", lazy = false, priority = 100 },
  { "nvim-tree/nvim-web-devicons" },
  { "nvim-lualine/lualine.nvim", lazy = true },
  { "akinsho/bufferline.nvim", lazy = true },
  { "nvim-tree/nvim-tree.lua", lazy = true },
  { "famiu/bufdelete.nvim" },
  { "karb94/neoscroll.nvim" },
  { "nvim-telescope/telescope.nvim", cmd = "Telescope", dependencies = "nvim-lua/plenary.nvim" },
  { "goolord/alpha-nvim", lazy = true },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    dependencies = "nvim-treesitter/nvim-treesitter-context",
  },
  { "lukas-reineke/indent-blankline.nvim", cmd = "IndentBlanklineRefresh" },
  {
    "NeogitOrg/neogit",
    lazy = true,
    cmd = "Neogit",
    dependencies = "nvim-lua/plenary.nvim",
  },
  {
    "hrsh7th/nvim-cmp",
    event = "InsertEnter",
    dependencies = {
      "hrsh7th/cmp-nvim-lsp",
      "hrsh7th/cmp-buffer",
      "hrsh7th/cmp-path",
      "hrsh7th/cmp-cmdline",
      "saadparwaiz1/cmp_luasnip",
      "windwp/nvim-autopairs",
    },
  },
  {
    "L3MON4D3/LuaSnip",
    -- follow latest release.
    version = "v2.*",
    dependencies = { "rafamadriz/friendly-snippets" },
  },
  { "lewis6991/gitsigns.nvim" },
  { "numToStr/Comment.nvim" },
  { "folke/todo-comments.nvim", lazy = true, dependencies = "nvim-lua/plenary.nvim" },
  {
    "williamboman/mason.nvim",
    build = ":MasonUpdate",
    dependencies = {
      "williamboman/mason-lspconfig.nvim",
      "neovim/nvim-lspconfig",
      "onsails/lspkind.nvim",
      "rcarriga/nvim-dap-ui",
      "mfussenegger/nvim-dap",
      "jay-babu/mason-nvim-dap.nvim",
    },
  },
  { "ray-x/lsp_signature.nvim", event = "VeryLazy" },
  {
    "folke/trouble.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    opts = {
      -- your configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    },
  },
  { "hedyhli/outline.nvim", cmd = "Outline" },
  {
    "nvim-neorg/neorg",
    build = ":Neorg sync-parsers",
    -- tag = "*",
    dependencies = { "nvim-lua/plenary.nvim" },
  },
  { "akinsho/toggleterm.nvim", cmd = "ToggleTerm", version = "*", config = true },
  { "SmiteshP/nvim-navic", lazy = true, dependencies = "neovim/nvim-lspconfig" },
  {
    "folke/noice.nvim",
    event = "VeryLazy",
    dependencies = {
      -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
      "MunifTanjim/nui.nvim",
      -- OPTIONAL:
      --   `nvim-notify` is only needed, if you want to use the notification view.
      --   If not available, we use `mini` as the fallback
      "rcarriga/nvim-notify",
    },
  },
}, {
  concurrency = 4,
  git = {
    url_format = git_url .. "%s.git",
  },
})
